<?php

class Engine_User {
    protected $id = null;
    protected $data = array();
    protected $permissions = null;

    public function __set($name, $value) {
            $this->data[$name] = $value;
    }

    public function __get($name) {
        return $this->data[$name];
    }

    public function getPermissionsById($userId) {
        $db = Application_Bootstrap::getDbAdapter();
        return $db->selectCol("SELECT DISTINCT (p.alias)
                            FROM user u
                            LEFT JOIN role r on r.id = u.role
                            JOIN role2permission rp ON rp.roleId = r.id
                            LEFT JOIN permission p on rp.permissionId = p.id
                            WHERE p.statusId = 0 AND u.id = $userId");
    }
}